import React from 'react';
import CommonList from '../../../components/CommonLists/list';
import { Button, Tooltip } from 'antd';

class PermissionList extends CommonList {
  constructor(props) {
    super(props);
    this.api = 'permission';
    this.tableParams = {
      pagination: {
        showQuickJumper: true,
        total: props.list.length,
        showTotal: (total) => {
          return `总共 ${total} 条`;
        },
        showSizeChanger: true,
        pageSizeOptions: ['5', '10', '15', '20']
      }
    }

    this.columns = [
      {
        title: '权限',
        key: 'name',
        render: (text, record) => {
          return (
            <Tooltip title={record.name} placement='topLeft'>
              <div className="overflowtext">
                <Button type='link' onClick={this.assign.bind(this, record.id)}>
                  {record.name}
                </Button>
              </div>
            </Tooltip>
          );
        },
      },
      {
        title: '备注',
        dataIndex: 'remark',
        key: 'remark',
        render: (text, record) => {
          return (
            <Tooltip title={text} placement='topLeft'>
              {text}
            </Tooltip>
          );
        },
      },
      {
        title: '创建者',
        dataIndex: 'create_by',
        key: 'create_by',
        render: (text, record) => {
          return (
            <Tooltip title={text} placement='topLeft'>
              {text}
            </Tooltip>
          );
        },
      },
      {
        title: '创建时间',
        dataIndex: 'create_at',
        key: 'create_at',
        render: (text, record) => {
          return (
            <Tooltip title={text} placement='topLeft'>
              {text}
            </Tooltip>
          );
        },
      },
      {
        title: '更新者',
        dataIndex: 'update_by',
        key: 'update_by',
        render: (text, record) => {
          return (
            <Tooltip title={text} placement='topLeft'>
              {text}
            </Tooltip>
          );
        },
      },
      {
        title: '更新时间',
        dataIndex: 'update_at',
        key: 'update_at',
        render: (text, record) => {
          return (
            <Tooltip title={text} placement='topLeft'>
              {text}
            </Tooltip>
          );
        },
      }
    ];
  }
  componentDidMount() {}

  assign = id => {
    this.props.history.push(`/system/permission/${id}/edit`);
  };
}

export default PermissionList;
